t1 := day1; (* set days left in the actual month *)
t2 := day2;
IF (year1 = 1582) AND (month1 = 10) THEN
IF (day1 < 5) AND GregorianDaySmaller(day1,month1,year1,day2,month2,year2) AND GregorianDaySmaller(day2,month2,year2,1,11,1582) AND GregorianDayGreater(day2,month2,year2,14,10,1582) THEN
t2 := t2 - 10;
END;
IF day1 > 14 THEN
IF GregorianDaySmaller(day1,month1,year1,day2,month2,year2) AND GregorianDayGreater(day2,month2,year2,31,10,1582) THEN
t2 := t2 +10;
END;
IF GregorianDayGreater(day1,month1,year1,day2,month2,year2) AND GregorianDaySmaller(day2,month2,year2,5,10,1582) THEN
t1 := t1 -10;
END;
END;
END;
IF (year2 = 1582) AND (month2 = 10) AND (day2 > 14) THEN
IF GregorianDaySmaller(day2,month2,year2,day1,month1,year1) AND GregorianDayGreater(day1,month1,year1,31,10,1582) THEN
t1 := t1 +10;
END;
IF GregorianDayGreater(day2,month2,year2,day1,month1,year1) AND GregorianDaySmaller(day1,month1,year1,1,10,1582) THEN
t2 := t2 -10;
END;
END;
WHILE month1 > 1 DO (* calc days left by the gone month of the year1 *)
DEC(month1);
t1 := t1 + GregorianMonthDays(month1,year1);
END;
WHILE month2 > 1 DO (* calc days left by the gone month of the year2 *)
DEC(month2);
t2 := t2 + GregorianMonthDays(month2,year2);
END;
WHILE year1 > year2 DO (* calc days of diff years *)
DEC(year1);
t1 := t1 + GregorianYearDays(year1);
END;
WHILE year1 < year2 DO (* calc days of diff years *)
t1 := day1; (* set days left in the actual month *)
t2 := day2;
IF (year1 = 1582) AND (month1 = 10) THEN
IF (day1 < 5) AND HeisDaySmaller(day1,month1,year1,day2,month2,year2) AND HeisDaySmaller(day2,month2,year2,1,11,1582) AND HeisDayGreater(day2,month2,year2,14,10,1582) THEN
t2 := t2 - 10;
END;
IF day1 > 14 THEN
IF HeisDaySmaller(day1,month1,year1,day2,month2,year2) AND HeisDayGreater(day2,month2,year2,31,10,1582) THEN
t2 := t2 +10;
END;
IF HeisDayGreater(day1,month1,year1,day2,month2,year2) AND HeisDaySmaller(day2,month2,year2,5,10,1582) THEN
t1 := t1 -10;
END;
END;
END;
IF (year2 = 1582) AND (month2 = 10) AND (day2 > 14) THEN
IF HeisDaySmaller(day2,month2,year2,day1,month1,year1) AND HeisDayGreater(day1,month1,year1,31,10,1582) THEN
t1 := t1 +10;
END;
IF HeisDayGreater(day2,month2,year2,day1,month1,year1) AND HeisDaySmaller(day1,month1,year1,1,10,1582) THEN
t2 := t2 -10;
END;
END;
WHILE month1 > 1 DO (* calc days left by the gone month of the year1 *)
DEC(month1);
t1 := t1 + HeisMonthDays(month1,year1);
END;
WHILE month2 > 1 DO (* calc days left by the gone month of the year2 *)
DEC(month2);
t2 := t2 + HeisMonthDays(month2,year2);
END;
WHILE year1 > year2 DO (* calc days of diff years *)
DEC(year1);
t1 := t1 + HeisYearDays(year1);
END;
WHILE year1 < year2 DO (* calc days of diff years *)